package com.lkd.shoppingcart.service.impl;

import com.lkd.shoppingcart.dao.CartDao;
import com.lkd.shoppingcart.dao.impl.CartDaoImpl;
import com.lkd.shoppingcart.entity.Cart;
import com.lkd.shoppingcart.service.CartService;

public class CartServiceImpl implements CartService {
	
	private CartDao cartDao = new CartDaoImpl();

	@Override
	public void addToCart(Integer userId, Integer productId, Integer quantity) {
		cartDao.addToCart(userId, productId, quantity);
	}

	@Override
	public void removeById(Integer userId, Integer productId) {
		cartDao.removeById(userId, productId);
	}

	@Override
	public void removeByUserId(Integer userId) {
		cartDao.removeByUserId(userId);
	}

	@Override
	public void updateQuantityById(Integer userId, Integer productId, Integer quanity) {
		cartDao.updateQuantityById(userId, productId, quanity);
	}
	
	@Override
	public int queryForCount(Integer userId) {
		return cartDao.queryForCount(userId);
	}

	@Override
	public Cart queryByUserId(Integer userId) {
		return new Cart(cartDao.queryByUserId(userId));
	}

	@Override
	public boolean cartExists(Integer userId, Integer productId) {
		return cartDao.cartExists(userId, productId);
	}

}
